package com.mofish.zbserver.user.login.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mofish.zbserver.user.login.LoginDto;
import com.mofish.zbserver.user.login.LoginService;
import com.mofish.zbserver.user.login.dao.LoginDao;

@Service
@Transactional
public class LoginServiceImpl implements LoginService {

	@Resource
	private LoginDao loginDao;

	/**
	 * 检查用户是否登录成功
	 * @param loginDto 包含用户uid与密码
	 * @return 成功登录返回true，否则返回false
	 */
	@Override
	public Boolean checkLogin(LoginDto loginDto) {
		return loginDao.selectUserCountByIdAndPwd(loginDto) == 1;
	}

	/**
	 * 根据用户昵称获取用户id
	 * @param u_name 用户昵称
	 * @return 用户id
	 */
	@Override
	public String getU_idByU_name(String u_name) {
		return loginDao.selectU_idByU_name(u_name);
	}

}
